import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {
  AdvertiserReferralRelationVO,
  AdvertiserReferralRelationForm,
  AdvertiserReferralRelationQuery
} from '@/api/oce/advertiserReferralRelation/types';

/**
 * 查询推广链接-广告主关联列表
 * @param query
 * @returns {*}
 */

export const listAdvertiserReferralRelation = (query?: AdvertiserReferralRelationQuery): AxiosPromise<AdvertiserReferralRelationVO[]> => {
  return request({
    url: '/oce/advertiserReferralRelation/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询推广链接-广告主关联详细
 * @param advertiserReferralId
 */
export const getAdvertiserReferralRelation = (advertiserReferralId: string | number): AxiosPromise<AdvertiserReferralRelationVO> => {
  return request({
    url: '/oce/advertiserReferralRelation/' + advertiserReferralId,
    method: 'get'
  });
};

/**
 * 新增推广链接-广告主关联
 * @param data
 */
export const addAdvertiserReferralRelation = (data: AdvertiserReferralRelationForm) => {
  return request({
    url: '/oce/advertiserReferralRelation',
    method: 'post',
    data: data
  });
};

/**
 * 修改推广链接-广告主关联
 * @param data
 */
export const updateAdvertiserReferralRelation = (data: AdvertiserReferralRelationForm) => {
  return request({
    url: '/oce/advertiserReferralRelation',
    method: 'put',
    data: data
  });
};

/**
 * 删除推广链接-广告主关联
 * @param advertiserReferralId
 */
export const delAdvertiserReferralRelation = (advertiserReferralId: string | number | Array<string | number>) => {
  return request({
    url: '/oce/advertiserReferralRelation/' + advertiserReferralId,
    method: 'delete'
  });
};

/**
 * 获取广告主详细信息
 * @param params
 */
export const getQueryAdvertiserInfo = (id: string | number): AxiosPromise<AdvertiserReferralRelationVO> => {
  return request({
    url: '/oce/advertiserReferralRelation/queryAdvertiserInfo',
    method: 'get',
    params: { thirdAdvertiserId: id }
  });
};
